//  小仓库：组件相关配置
import { defineStore } from "pinia";
import columns from "@/views/home/components/column";
import type { StettingState } from "./types/type";
const useLayoutSettingStore = defineStore("SettingStore", {
  state: (): StettingState => {
    return {
      //  显示隐藏图表
      fold: false,
      foldLeft: false,
      foldRight: false,
      //  关闭筛选数据列表弹框
      selectionDataListShow: false,
      //  资产列表
      propertyShow: false,
      //  设置表头
      setTableHeaderShow: false,
      //  表头数据
      column: [],
      columnType: columns["设置"],
      //  表头名称
      columnName: "",
      //  详情
      detailsShow: false,
      //  高级搜索
      advancedSearchShow: false,
      //  图层
      layerList: ["lamp", "lamp_post", "loop", "transformer"],
      //  资产统计名称
      propertyName: "武汉市",
      //  地图主题切换
      mapTheme: true,
      //  框选状态
      mouseToolStutas: false,
      //  地图层级
      zoom: 9,
    };
  },
  actions: {
    //  获取表头
    setColumnName(value: string) {
      this.columnName = value;
    },
    //  获取表头数据
    setColumn() {
      let loc: any = localStorage.getItem("columns");
      if (loc) {
        loc = JSON.parse(loc);
        this.columnName === "设置"
          ? (this.columnType = loc[this.columnName])
          : (this.column = loc[this.columnName]);
        return;
      }
      const list: any = columns;
      this.columnName === "设置"
        ? (this.columnType = list[this.columnName])
        : (this.column = list[this.columnName]);
    },
  },
  getters: {},
});

export default useLayoutSettingStore;
